The present invention relates to the field of computer graphics and, more particularly, to the application of texture mapping to generate pixel values.
Rendering of realistic images (e.g., two- or three-dimensional images) is one of the main goals of graphics system designers. Rendering images of real or imaginary objects typically involves generating geometric models (e.g., polygons) of objects and applying lighting effects to polygonal surfaces. In computer graphics, surfaces of an object are generally modeled by a polygonal mesh, which is a collection of vertices, edges, and/or polygons. A mesh of polygons may be produced from a variety of sources such as an application, tesselated NURBS surfaces, spheres, cones, etc. The vertices may be connected by edges and a sequence of edges or vertices may define one or more polygons.
Rendering of realistic 3D graphics requires accurate and efficient modeling of 3D surfaces based upon the position, orientation, and characteristics of the surfaces and the light sources illuminating them. In particular, the interaction between lights and surfaces must be modeled for rendering. To accurately model lighting effects, conventional computer graphics systems have typically implemented a variety of lighting models and shading techniques to generate light values at individual pixels of a graphics primitive such as a polygon. A co-pending U.S. patent application Ser. No. 09/265,507, entitled “Method and Device for Generating Per-Pixel Light Values,” by inventor David C. Tannenbaum et al., describes several exemplary lighting models and shading techniques.
Conventional lighting models typically model one or more lighting effects such as ambient light, diffuse reflection, specular reflection, and spotlighting, each of which is well known in the art. The ambient light accounts for a lighting effect resulting from multiple reflections of light from the surfaces present in a scene. On the other hand, the diffuse reflection models reflection of light off a dull, matte surface. In this model, the reflected light from the surface falls off uniformly as a function of an angle between N and L, where N is a normal vector at a surface point and L is a light vector. The diffuse light fall off in the diffuse reflection model is typically modeled by using a dot product term N·L.
Similarly, the specular reflection accounts for reflection of light off a shiny surface. When light from a light source is reflected off a surface, the reflected light falls off approximately exponentially from the direction of reflection vector R as seen from the direction of view vector V. For example, the fall off may be modeled by cos8α, where s is a surface material's specular reflection coefficient and α is an angle between the vectors R and V. In practice, a dot product power term (N·H)s is often used in place of cos8α to model specular reflection at a surface point, where N is a normal vector and H is a half-angle vector. Both the diffuse and specular reflection models assume that a light source (e.g., L vector) radiates light uniformly in all directions.
In contrast, the spotlight model adds a direction to a positional light source to allow modeling of directional lights. That is, a spotlight is a special type of light source that has a direction as well as a position. For example, a positional light source may function as a spotlight by restricting the shape of the light to a cone. The direction of the spotlight is the direction in which the light points. The spotlight thereby simulates a cone of light, which may have a fall-off in intensity based upon the distance from the center of the cone of light.
The ambient, diffuse, specular, and spotlight models are well known and are described in greater detail in Computer Graphics: Principles and Practice by James D. Foley et al., Addison-Wesley (1996), ISBN 0-201-84840-6, which is incorporated herein by reference and constitutes a portion of the background against which the present invention was developed. Additionally, the OpenGL™ (versions 1.1 and 1.2) application programming interface (API) describes various lighting models such as spotlighting, diffuse light reflection, specular light reflection, and related parameters for implementing such models. The OpenGL™ (versions 1.1 and 1.2) graphics application programming interface is commercially available from Silicon Graphics, Inc., the assignee of the present application, and is incorporated herein by reference.
By way of example, the OpenGL™ graphics application programming interface, version 1.1 evaluates a light value C at a pixel by implementing an exemplary lighting equation as follows:C=ecm+acm*acs+att*spot[acm*acl+(N·L)dcm*dcl+(N·H)sscm*scl]  Eq. (1)The parameters in Equation (1) are defined as follows:
ecm=emission material color,
acm=ambient material color,
acs=global ambient light color,
att=attenuation factor,
spot=spotlight effect,
acl=ambient light color,
dcm=diffuse material color,
dcl=diffuse light color,
scm=specular material color,
scl=specular light color,
s=specular exponent,
N=outward surface normal vector at the pixel,
L=light-source vector (pointing from pixel to light) at the pixel, and
H=half-angle vector between light-source vector and eye vector at the pixel.
In Equation (1), the attenuation factor att can be further defined as 1/[kc+kld+kqd2], where d is the distance between a light's position and a pixel, kc represents constant attenuation, kl is linear attenuation, and kq represents quadratic attenuation. Those skilled in the art will appreciate that Equation (1) may be evaluated for each light source illuminating a pixel of interest.
In implementing a light equation to evaluate light color values, conventional techniques have typically assigned constant values for many of the parameters in the equations. For instance, conventional techniques typically assign a constant value to material parameters such as the ambient, diffuse, specular, and emission material colors. That is, all pixels within a graphics primitive (e.g., polygon) are assigned the same constant value for a given material parameter. The assignment of constant parameter values is relatively easy and inexpensive to implement in a computer system.
Unfortunately, while the constant modeling technique is simple and inexpensive to implement, it does not produce highly realistic surfaces. The reason for this is that the constant assignment scheme is based on the assumption that the entire surface of the primitive is constant. In reality, however, many surfaces of objects are not constant. Instead, the surface of a graphics primitive often has characteristics that vary over the surface of the primitive.
By way of example, a marble tabletop may not be equally shiny everywhere on its surface. As another example, consider a light shining through dense vegetation such as trees in a forest. In such a case, the conventional constant parameter assignment scheme may not be able to render a substantially realistic image of the light shining through the trees.
To model a surface that varies over the associated primitive, one prior art method has used a non-constant surface description to model the varying diffuse material properties of the surfaces such as the trees and marble tabletop. In this method, a unique color is assigned to each vertex of the polygon and then interpolated to obtain a per-pixel color. However, while the modeling of varying diffuse lights somewhat improves rendering of a varying surface, it does not adequately model other parameters that may vary over the surface. For example, parameters such as the ambient, specular, and emission material color may also vary over the surface. In addition, the parameters in the dot product terms of lighting Equation (1) such as the normal vector N, the specular exponent s, and the like generally vary over a surface in practice.
Thus, what is needed is a method, device, and system that can generate per-pixel color values by modeling parameters that vary over a surface of a graphics primitive.